package com.zzyl.controller;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.FloorDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.mapper.NursingPlanProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.utils.ObjectUtil;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController extends BaseController {
    @Autowired
    private NursingProjectService nursingProjectService;



    @GetMapping
    @ApiOperation(value = "分页查询护理项数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理项目名称", required = false, dataType = "String", paramType = "query"),
    })
    public ResponseResult<PageResponse<NursingProjectVo>> selectByPage(Integer pageNum,
                                                                       Integer pageSize,
                                                                       Integer status,
                                                                       String name
    ) {
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.selectByPage(pageNum, pageSize, status, name);
        return success(pageInfo);
    }

    /**
     * 新增护理项目
     *
     * @param nursingProjectDto
     * @return
     */
    @PostMapping()
    @ApiOperation(value = "添加护理项目", notes = "传入护理项目详细信息，返回结果")
    public ResponseResult addNursing(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addNuringProject(nursingProjectDto);
        return success();
    }
    /**
     * 新增护理项目
     *
     * @param nursingProjectDto
     * @return
     */
    @PutMapping()
    @ApiOperation(value = "编辑护理项目", notes = "传入护理项目详细信息，返回结果")
    public ResponseResult editNursing(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.editNursingProject(nursingProjectDto);
        return success();
    }

    /**
     * 根据id查询护理项目
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目")
    public ResponseResult<NursingProjectVo> selectById(@PathVariable Integer id){
      NursingProjectVo vo=  nursingProjectService.selectById(id);

        return success(vo);
    }

    /**
     * 根据id修改状态
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "启用禁用状态")
    public ResponseResult editStatus(@PathVariable Integer id,@PathVariable Integer status){
        nursingProjectService.editStatus(id,status);
        return success();
    }

    /**
     * 根据id删除护理项目
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    @ApiOperation(value = "根据id删除某一项护理")
    public ResponseResult deleteById(@PathVariable Integer id){
        nursingProjectService.deleteById(id);
        return success();
    }

    @GetMapping("/all")
    @ApiOperation(value = "查询所有护理项目")
    public ResponseResult<List<NursingProjectVo>> findAll(){
       List<NursingProjectVo> vo= nursingProjectService.findAll();
        return success(vo);
    }
}
